package org.example.danli;

/**
 * {@code @BelongsProject:}xkLab
 * {@code @BelongsPackage:}org.example.danli
 * {@code @Author:} Xukai
 * {@code @CreateTime:}2025-06-17  15:03
 * {@code @Description:}TODO
 * {@code @Version:}1.0
 */
public class test {
    public static void main(String[] args) {
        GirlFriend girlFriend = GirlFriend.getInstance();
        System.out.println(girlFriend);
    }
}

class GirlFriend{
    private String name;
    //构造对象
    private static GirlFriend girlFriend;
    //将构造器私有化
    private GirlFriend(String name){
        this.name = name;
    }
    //给外界暴露调用
    public static GirlFriend getInstance() {
        if (girlFriend==null){
            girlFriend = new GirlFriend("girlFriend");
        }
        return girlFriend;
    }

    //美化输出，重写toString
    @Override
    public String toString() {
        return name;
    }
}